package src;

/**
 * Created with IntelliJ IEDA.
 * Description:
 * User:86186
 * Date:2022-07-10
 * Time:14:34
 */
class Alg<T extends Comparable<T>>{//泛型方法
    public T findMaxValue(T[] array){
        T maxVal=array[0];
        for (int i = 1; i < array.length; i++) {
            if(array[i].compareTo(maxVal)>0){
                maxVal=array[i];
            }
        }
        return maxVal;
    }
}
class alg2{
    //静态方法
    public static <T extends Comparable<T>> T findMAXValue (T array[]){

        T maxVal=array[0];
        for (int i = 1; i < array.length; i++) {
            if(array[i].compareTo(maxVal)>0){
                maxVal=array[i];
            }
        }
        array.char
        return maxVal;
    }
}

class alg3{
    //泛型方法：成员方法
    public <T extends Comparable<T>> T findmax(T[] array){
        T maxVal=array[0];
        for (int i = 1; i < array.length; i++) {
            if(array[i].compareTo(maxVal)>0){
                maxVal=array[i];
            }
        }
        return maxVal;
    }
}

public class Test {
    public static void main(String[] args) {
        Integer array[]={11,56,89,32};
        System.out.println(alg2.findMAXValue(array));
    }


    public static void main1(String[] args) {
        Alg <Integer> num = new Alg<>();//创建对象
        Integer array[]={11,56,89,32};
        System.out.println(num.findMaxValue(array));//要想调用这个方法必须要有创建对象
    }
}

